home *** CD-ROM | disk | FTP | other *** search
- Public Class OutputCachingForm
- Inherits System.Web.UI.Page
-
- Protected WithEvents btnRefresh As System.Web.UI.WebControls.Button
- Protected WithEvents txtValue As System.Web.UI.WebControls.TextBox
- Protected WithEvents lblTime As System.Web.UI.WebControls.Label
-
- #Region " Web Form Designer Generated Code "
-
- 'This call is required by the Web Form Designer.
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
-
- End Sub
-
- Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
- 'CODEGEN: This method call is required by the Web Form Designer
- 'Do not modify it using the code editor.
- InitializeComponent()
- End Sub
-
- #End Region
-
- ' Set the following constant to True to override @OutputCache settings
- ' with settings enforced through code
- #Const USE_RESPONSECACHE_OBJECT = False
-
- Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
- #If USE_RESPONSECACHE_OBJECT Then
- Response.Cache.SetCacheability(HttpCacheability.Server)
- Response.Cache.SetExpires(Now.AddSeconds(1))
-
- ' these statements implement validate callback.
- Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches)
- Response.Cache.AddValidationCallback(AddressOf ValidateCache, Nothing)
- #End If
-
- ' the job of this page is just to append the current time to the
- ' contents of the lblTime Label control
- lblTime.Text &= "Current time is " & Date.Now.ToLongTimeString & "<br>"
- End Sub
-
- ' this event fires when the cache is invalidated
-
- Public Sub ValidateCache(ByVal context As HttpContext, ByVal data As Object, ByRef status As HttpValidationStatus)
- If context.Request.QueryString("Refresh") <> "" Then
- status = HttpValidationStatus.Invalid
- Else
- status = HttpValidationStatus.Valid
- End If
- End Sub
-
- End Class
-